<html>
<head><meta charset="utf-8"><title>AllocRef and [u8].size · t-libs/wg-allocators · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/index.html">t-libs/wg-allocators</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/AllocRef.20and.20.5Bu8.5D.2Esize.html">AllocRef and [u8].size</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212452669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/AllocRef%20and%20%5Bu8%5D.size/near/212452669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Chartier <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/AllocRef.20and.20.5Bu8.5D.2Esize.html#212452669">(Oct 06 2020 at 16:29)</a>:</h4>
<p>Another question, if AllocRef::alloc can return a larger size array than I asked for, does that mean I have to store that size in order to AllocRef::dealloc properly? (assuming I  want to turn my NonNull&lt;[u8]&gt; into something more useful that may not exactly align with the u8s I got back)</p>



<a name="212490877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/AllocRef%20and%20%5Bu8%5D.size/near/212490877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/AllocRef.20and.20.5Bu8.5D.2Esize.html#212490877">(Oct 06 2020 at 21:54)</a>:</h4>
<p>i believe the contract is that you pass the pointer and pass the same Layout as before. If the allocator is handing you 64 when you asked for 50, that's its business to track.</p>



<a name="212495282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/AllocRef%20and%20%5Bu8%5D.size/near/212495282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/AllocRef.20and.20.5Bu8.5D.2Esize.html#212495282">(Oct 06 2020 at 22:44)</a>:</h4>
<p>If the allocators hands you 64 when you asked for 50 then you can pass any value between 50 and 64 when freeing.</p>



<a name="212560118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/AllocRef%20and%20%5Bu8%5D.size/near/212560118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Chartier <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/AllocRef.20and.20.5Bu8.5D.2Esize.html#212560118">(Oct 07 2020 at 13:45)</a>:</h4>
<p>Perfect! That's great to know.  The AllocRef interface is super clean. You guys have done great work.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>